﻿#include "HttpClient.h"
#include <iostream>
int main() {
    auto &client = HttpClient::getInstance();
    // GET 示例
    {
        std::cout << "=== GET demo1 ===" << std::endl;
        HttpResponse r = client.get("http://httpbin.org/get");
        std::cout << "status: " << r.status_code << std::endl;
        if (!r.error.empty()) std::cerr << "error: " << r.error << std::endl;
        std::cout << "body: " << r.body.substr(0, 400) << std::endl;
    }

    // POST JSON 示例
    {
        std::cout << "\n=== POST JSON demo ===" << std::endl;
        std::string json = R"({"name":"Alice","age":25})";
        HttpResponse r = client.postJson("http://httpbin.org/post", json);
        std::cout << "status: " << r.status_code << std::endl;
        if (!r.error.empty()) std::cerr << "error: " << r.error << std::endl;
        std::cout << "body: " << r.body.substr(0, 400) << std::endl;
    }

    return 0;
}
